import hashlib as hl
import pandas as pd
import os
os.getcwd()
os.chdir('d:/项目/贷中模型优化/')
#客户数据编号、姓名、身份证号、手机号、申请日期
def md5_transfer():
    df = pd.read_excel('惠今数据匹配.xlsx').astype(str)
    df['姓名'] = df['姓名'].apply(lambda x: hl.md5(x.encode(encoding='utf-8')).hexdigest())
    df['身份证号'] = df['身份证号'].apply(lambda x: hl.md5(x.encode(encoding='utf-8')).hexdigest())
    df['手机号'] = df['手机号'].apply(lambda x: hl.md5(x.encode(encoding='utf-8')).hexdigest())
    df['申请日期'] = pd.to_datetime(df['申请日期'])
    df['申请日期'] = df['申请日期'].apply(lambda x: x.strftime('%Y-%m-%d'))
    # df['加密方式'] = 'MD5'
    # df['补充信息'] = ''
    df.to_excel('惠今数据匹配md5.xlsx', index=False)
    return df

md5_transfer()